<template>
  <div class="book-piece">
    <!-- 收藏 -->
    <div class="book-item">
      <router-link
        tag="div"
        class="item"
        v-for="(item, index) in bookpiece"
        :key="index"
        :to="'/noveldetail?id=' + item.id"
        >

        <div class="item-img">
          <img :src="item.fictionImg" alt="" />
        </div>
        <span class="item-title">{{ item.titleName }}</span>
      </router-link>
    </div>
  </div>
</template>

<script>
import { getFictionApi } from "../api/novelmain.js";
export default {
  name: "BookPiece",
  data() {
    return {
      fiction: null,
      bookpiece: null,
      shoucang: null,
      shoucangs: null,
    };
  },
  methods: {},
  created() {
    getFictionApi().then((data) => {
      // console.log(this.fiction);
      this.fiction = data.fiction;
    });
    if (localStorage.shoucang) {
      this.bookpiece = JSON.parse(localStorage.getItem("shoucang"));
      console.log(this.bookpiece);
    }
  },
};
</script>

<style lang="scss" scoped>
.book-item {
  display: -webkit-box;
  background: #fff;
  padding: 20px 4px 15px 4px;
  .item {
    -webkit-box-flex: 1;
    width: 0;
    margin: 0 8px 0 8px;
    text-align: center;
    img {
      width: 80px;
      height: 100px;
    }
    .item-title {
      margin: 0;
      display: block;
      line-height: 23px;
      margin: 0 auto;
      font-size: 11px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
}
</style>